Conversation
Includes per-hop slippage for single swaps and flipped output/input ratio formula with 1e36 precision.
🤖 Claude Code Review
SummaryThis PR adds two major features to the Universal Router:
AnalysisPer-hop Slippage ImplementationThe implementation correctly handles the complex ordering of exact-output swaps where trading hops execute in reverse order:
The Breaking Change ConsiderationsThe ABI for V2 and V3 swap commands has changed - all calls now require a 6th parameter ( Test CoverageThe foundry tests (
Code QualityThe implementation is clean:
VerdictThe implementation is correct and well-tested. The features are additive with sensible defaults (empty array = disabled). No bugs, security issues, or data corruption risks identified. 💡 Want a fresh review? Add a comment containing |
There was a problem hiding this comment.
📋 Review verdict: APPROVE
👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.
This formal review submission is for the verdict only.
Superseded by new review after PR update
There was a problem hiding this comment.
📋 Review verdict: APPROVE
👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.
This formal review submission is for the verdict only.
Superseded by new review after PR update
There was a problem hiding this comment.
📋 Review verdict: APPROVE
👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.
This formal review submission is for the verdict only.
Superseded by new review after PR update
There was a problem hiding this comment.
📋 Review verdict: APPROVE
👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.
This formal review submission is for the verdict only.
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
| uint256 amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput); | ||
| if (minHopPriceX36.length != 0) { | ||
| uint256 price = amountOutput * Constants.PRICE_PRECISION / amountInput; |
There was a problem hiding this comment.
Btw this operation will overflow for any values over 2^137, which I assume is fine but just flagging since seems like V2 amounts are uint256 instead of uint128 like v3/v4
| /// @param recipient The address that will receive payment | ||
| /// @param portion Portion of whole balance of the contract, where 1e18 represents 100% | ||
| function payPortionFullPrecision(address token, address recipient, uint256 portion) internal { | ||
| if (portion > 1e18) revert InvalidPortion(); |
There was a problem hiding this comment.
Not immediately clear that 1e18 is precision value. Maybe use a constant here?
🤖 Claude Code ReviewStatus: The review was completed but there was an error posting inline comments. Raw Review OutputPlease check the workflow logs for details. |
🤖 Claude Code ReviewStatus: ❌ Error
|
Summary
0x07): New payment command with 1e18 precision (vs 10,000 bips), enabling exact fractional payments like 1/3uint256[] maxHopSlippageparameter to all 4 V2/V3 swap commands (V3_SWAP_EXACT_IN,V3_SWAP_EXACT_OUT,V2_SWAP_EXACT_IN,V2_SWAP_EXACT_OUT), matching V4's convention whereprice = amountOut * 1e36 / amountInmaxHopSlippagein V4 single-swap structsTest Plan
✨ Claude-Generated Content
Summary
Universal Router v2.1.1 introduces high-precision payment commands and per-hop slippage protection for V2/V3 swaps, aligning with V4's conventions.
Changes
New Commands
0x07): Payment command with 1e18 precision (vs 10,000 bips), enabling exact fractional payments like 1/3Per-hop Slippage Protection
uint256[] minHopPriceX36parameter to all V2/V3 swap commands:V3_SWAP_EXACT_IN,V3_SWAP_EXACT_OUTV2_SWAP_EXACT_IN,V2_SWAP_EXACT_OUTamountOut * 1e36 / amountInNew Errors
V2TooLittleReceivedPerHop,V2InvalidHopPriceLengthin V2SwapRouterV3TooLittleReceivedPerHop,V3TooMuchRequestedPerHop,V3HopPriceAndPathLengthMismatchin V3SwapRouterInvalidPortionin Payments moduleLibrary Updates
toUint256Arrayhelper in BytesLib for decoding hop slippage arraysPRICE_PRECISIONconstant (1e36) in ConstantsINCREASE_LIQUIDITY_FROM_DELTASaction check in V3ToV4MigratorBuild Configuration
bytecode_hash = "none"in foundry.tomlDependencies
minHopPriceX36in V4 single-swap structsTest Plan